<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">


    <body background="../resources/images/table/bg.jpg">

        <ui:composition template="./UserTemplate.xhtml">
            <ui:define name="content">
                <p:panel header="Now showing">
                    <p:carousel value="#{UsereventBean.listAvailableEvent()}"
                                var="item"
                                rows="5"
                                itemStyleClass="eventClass"
                                effect="easeInStrong">
                        <c:set var="title" value="${item.eventTitle}"/>
                        <h:panelGrid columns="1" style="width:100%" cellpadding="5">
                            <p:graphicImage width="180" height="269" value="#{item.eventImg}"/>

                            <p:commandLink style="color: red" value="${fn:substring(title,0,20)}" update="itemDialog" oncomplete="itemDialog.show()">
                                <f:setPropertyActionListener value="#{item}" target="#{UsereventBean.event}" />
                            </p:commandLink>

                            <h:outputText value="Category: #{item.category.categoryName}" />

                            <h:outputText value="#{item.releaseDate}" style="color: #66ccff">
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>
                            <h:commandLink title="Buy a ticket">
                                <h:graphicImage value="../resources/images/User/buy-ticket-button.png"/>
                            </h:commandLink>
                        </h:panelGrid>                        
                    </p:carousel>
                    <p:dialog header="Event Detail" widgetVar="itemDialog" width="200" height="175" modal="true">
                            <p:outputPanel id="eventDetail" style="text-align:center;" layout="block">

                                <p:graphicImage value="#{UsereventBean.event.eventImg}"/>
                                <h:panelGrid  columns="2" cellpadding="5">
                                    <h:outputText id="iventTitle" value="#{UsereventBean.event.eventTitle}" />

                                    <h:outputLabel for="category" value="Category: " />
                                    <h:outputText id="category" value="#{UsereventBean.event.category.categoryName}" />

                                    <h:outputLabel for="Time" value="Time: " />
                                    <h:outputText id="time" value="#{UsereventBean.event.releaseDate} to #{UsereventBean.event.endDate}" />

                                    <h:outputLabel for="info" value="Color: " />
                                    <h:outputText id="info" value="#{UsereventBean.event.eventInfo}"/>
                                </h:panelGrid>
                            </p:outputPanel>
                        </p:dialog>
                </p:panel>

                <p:panel header="Coming up">
                    <p:carousel value="#{UsereventBean.listNextEvent()}"
                                var="item"
                                rows="5"
                                itemStyleClass="eventClass"
                                effect="easeInStrong">
                        <c:set var="title" value="${item.eventTitle}"/>
                        <h:panelGrid columns="1" style="width:100%" cellpadding="5">
                            <p:graphicImage width="180" height="269" value="#{item.eventImg}"/>

                            <h:commandLink style="color: red" value="${fn:substring(title,0,20)}" action="Home"/>

                            <h:outputText value="Category: #{item.category.categoryName}" />

                            <h:outputText value="#{item.releaseDate}" style="color: #66ccff">
                                <f:convertDateTime pattern="dd/MM/yyyy"/>
                            </h:outputText>
                            <h:commandLink title="Buy a ticket">
                                <h:graphicImage value="../resources/images/User/buy-ticket-button.png"/>
                            </h:commandLink>
                        </h:panelGrid>
                    </p:carousel>
                </p:panel>
            </ui:define>
        </ui:composition>

    </body>
</html>
